package controller;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/logout")
public class LogoutServlet extends HttpServlet {

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("UTF-8");
        response.setContentType("application/json;charset=UTF-8");

//        // 使当前会话无效
//        request.getSession().invalidate();

        // 设置响应状态为200
        response.setStatus(200);

        // 返回成功的响应
        response.getWriter().write("退出登录成功");
        response.getWriter().flush();

//        打印
        System.out.println("退出登录成功");
    }
}

